<!DOCTYPE html>
<html 
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head></h:head>
<body>
		<h:form id="formTipoDocumento">

			<p:growl id="msgs" showDetail="true" life="1000" />
			<p:panel header="TipoDocumento" style="border: none;">

				<p:dataTable id="singleDT" var="td" value="#{tipoDocumentoBean.listTipoDocumento}"
					selection="#{tipoDocumentoBean.selectedTipoDocumento}" rowKey="#{td.nombreTipoDoc}"
					editable="true" style="width:50%" rows="5" paginator="true"
					paginatorPosition="bottom"
					paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}">

					<p:ajax event="rowEdit" listener="#{tipoDocumentoBean.onRowEdit}"
						update=":#{p:component('msgs')}" />
					<p:ajax event="rowEditCancel" listener="#{tipoDocumentoBean.onRowCancel}"
						update=":#{p:component('msgs')}" />

					<f:facet name="header">
						<p:outputPanel style="text-align:right">
							<h:outputText value="Buscar: " />
							<p:inputText id="globalFilter" onkeyup="PF('tipoDocumentoTable').filter()"
								style="width:150px" placeholder="Ingrese Tipo Documento" />
						</p:outputPanel>
					</f:facet>

					<p:column headerText="Tipo Documento" style="text-align:left">
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{td.nombreTipoDoc}" />
							</f:facet>
							<f:facet name="input">
								<p:inputText id="modelInput" value="#{td.nombreTipoDoc}"
									style="width:100%" />
							</f:facet>
						</p:cellEditor>
					</p:column>
					<p:column headerText="Modificar"
						style="width:70px;text-align: center">
						<p:rowEditor />
					</p:column>

					<p:column headerText="Eliminar"
						style="width:32px;text-align: center">
						<p:commandButton process="singleDT"
							update=":#{p:component('singleDT')}" icon="ui-icon-close"
							title="View" action="#{tipoDocumentoBean.eliminarTipoDocumento}">
							<f:setPropertyActionListener value="#{td}"
								target="#{tipoDocumentoBean.selectedTipoDocumento}" />

							<p:confirm header="Confirmación" message="Está seguro?"
								icon="ui-icon-alert" />
						</p:commandButton>
					</p:column>

				</p:dataTable>

				<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
					<p:commandButton value="Si" type="button"
						styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
					<p:commandButton value="No" type="button"
						styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
				</p:confirmDialog>

				<br />

				<p:fieldset id="panelNuevoTipoDocumento" legend="Nuevo" toggleable="true"
					toggleSpeed="500" collapsed="true" style="width:46%">
					<p:messages id="messages" autoUpdate="false" />
					<h:panelGrid columns="3" cellpadding="5">
						<h:outputLabel for="nomTipoDocumento" value="Nombre:" />
						<p:inputText id="nomTipoDocumento" required="true" label="Nombre tipo Documento"
							value="#{tipoDocumentoBean.tipoDocumento.nombreTipoDoc}" />
						<p:message for="nomTipoDocumento" display="icon" />
					</h:panelGrid>
					<p:separator id="separator" />
					<p:commandButton value="Guardar" id="ajax" process="@form"
						icon="ui-icon-disk" update=":#{p:component('formTipoDocumento')}"
						actionListener="#{TipoDocumentoBean.guardarTipoDocumento}" />
				</p:fieldset>
			</p:panel>

		</h:form>

</body>
</html>